package com.moji.controller.api;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjWorkOrder;
import com.moji.entity.dto.QueryWorkOrderDto;
import com.moji.service.MjWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 电子工单表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-08-16
 */
@RestController
@RequestMapping("web/auth/mjWorkOrder")
@Api(tags = "电子工单相关web接口(控制中心)", value = "电子工单相关web接口(控制中心)")
public class MjWorkOrderController {

    @Resource
    private MjWorkOrderService mjWorkOrderService;

    @PostMapping("/add")
    @ApiOperation(value = "新增",response = Boolean.class)
    public ApiResult add(@Validated @RequestBody MjWorkOrder mjWorkOrder){
        return ApiResult.ok(mjWorkOrderService.add(mjWorkOrder));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑",response = Boolean.class)
    public ApiResult edit(@Validated @RequestBody MjWorkOrder mjWorkOrder){
        return ApiResult.ok(mjWorkOrderService.edit(mjWorkOrder));
    }

    @GetMapping("/delete")
    @ApiOperation(value = "删除",response = Boolean.class)
    public ApiResult delete(@RequestParam("id") Long id){
        return ApiResult.ok(mjWorkOrderService.delete(id));
    }


    @PostMapping("/queryByPage")
    @ApiOperation(value = "分页查询",response = MjWorkOrder.class)
    public ApiResult queryByPage(@RequestBody QueryWorkOrderDto dto){
        return ApiResult.ok(mjWorkOrderService.queryByPage(dto));
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情",response = MjWorkOrder.class)
    public ApiResult detail(@RequestParam("id") Long id){
        return ApiResult.ok(mjWorkOrderService.detail(id));
    }
}

